import java.util.Random;

public class BinaryOperation_1 {
    public static void main(String[] args) {
        generateExerciseOfAdditionEquations();
        generateExerciseOfSubstactEquations();
    }

    //   生成50道加法算式
    static void generateExerciseOfAdditionEquations(){
        int m=0,n=0,v;
        System.out.println("----------------------------------\n-程序输出50道100以内的加法算式的习题-\n----------------------------------");
        for(int i=0; i<50; i++){
            do{
                n = generateOperand();
                m = generateOperand();
                v = m+n;
            }while(v >= 100);
            if (i%5 == 0) {
                System.out.print("\n"+(i+1)+"~"+(i+5) +": " + m+ " - " + n + " = " + v +"\t\t");
            }else{
                System.out.print(m+ " - " + n + " = " + v +"\t\t");
            }
        }
    }

    //   生成50道减法算式
    static void generateExerciseOfSubstactEquations(){
        int m=0,n=0,v;
        System.out.println("----------------------------------\n-程序输出50道100以内的减法算式的习题-\n----------------------------------");
        for(int i=0; i<50; i++){
            do{
                n = generateOperand();
                m = generateOperand();
                v = m-n;
            }while(v < 0);
            if (i%5 ==0) {
                System.out.print("\n"+(i+1)+"~"+(i+5) +": " + m+ " - " + n + " = " + v +"\t\t");
            }else{
                System.out.print(m+ " - " + n + " = " + v +"\t\t");
            }
        }
    }

    //    生成100以内的随机整数
    static int generateOperand(){
        Random random = new Random();
        return random.nextInt(101);
    }

}
